import ch.sfug.controls.EventButton;
import ch.sfug.events.ButtonEvent;
/**
 * @author loop
 */
class ch.sfug.utils.Banner {

    private var but:EventButton;
    private var url:String;
    private var target:String;

    public function Banner() {

        Stage.scaleMode = "noScale";
        Stage.align = "TL";
        Stage.showMenu = false;

        but = new EventButton( _root.but, true );
        but.addEventListener( ButtonEvent.RELEASE, onRelease, this );

        target = "_blank";
        url = this.getURL();

        readClickTag();
    }

    private function readClickTag():Void {
        var vari:Array = [ "ClickTAG", "clickTag", "clickTAG", "CLICKTAG", "url" ];
        for( var i:Number = 0; i < vari.length; i++ ) {
            if( _root[ vari[ i ] ] != undefined ) {
                url = _root[ vari[ i ] ];
                break;
            }
        }
    }

    /**
     * catch the event from the mouse
     */
    private function onRelease(  ):Void {
        getURL( url, target );
    }

    /**
     * ABSTRACT
     * returns a hardcoded url when necesarry
     */
    private function getURL():String {
        return "No target URL";
    }

}